Using material types

Material types define the property type of a material. By adjusting material property values defined by a material type, you set the appearance of a material. Each material type has a vertex shader and a fragment shader, which set the type of properties you can use in a material.

Kanzi Studio provides template projects that contain a default set of material types and shaders from the Kanzi Studio Asset Library located in <KanziInstallation>/Studio/Asset Library. When you create a new Kanzi Studio project you can select from different project templates based on the material types they provide:

You can:

Adding a material type to your project

You can add material types to your project in these ways:

Modifying the default Phong material types

The default FragmentPhong and VertexPhong material types support these properties:

Material type Basecolor texture Normalmap texture Reflection cube Morphing Skinning
FragmentPhong, VertexPhong
         
FragmentPhongCube, VertexPhongCube
    x    
VertexPhongMorph       x  
FragmentPhongSkinned, VertexPhongSkinned         x
FragmentPhongTextured, VertexPhongTextured x        
FragmentPhongTexturedCube, VertexPhongTexturedCube x   x    
FragmentPhongTexturedCubeNormalMap x x x    
VertexPhongTexturedMorph x     x  
FragmentPhongTexturedNormalMap x x      
FragmentPhongTexturedSkinned, VertexPhongTexturedSkinned x       x
           

To modify a VertexPhong or FragmentPhong material type:

  1. Select or add to your project one of the default VertexPhong or FragmentPhong material types. See Adding a material type to your project.
    For example, in the Library > Materials and Textures > Material Types select the VertexPhong material type.
  2. In the Properties in the Preprocessor Defines property set the properties of the material type.
    You can use this approach only for the FragmentPhong and VertexPhong material types. To modify the properties for other material types, you have to edit the shaders manually. See Editing shaders.
    You can set these Preprocessor Defines:For example, set the value of KANZI_SHADER_USE_BASECOLOR_TEXTURE to 1 and press the Enter key.
  3. In the Properties in the Uniforms property Kanzi Studio automatically updates the uniform arrays and if any uniform source types are missing, Kanzi Studio marks them with red type.
    In the Properties under the Property Types click Sync with Uniforms to add the missing properties for the materials that use this material type.

Adding a property to a material type

Add a property to a material type to make it suitable for your needs. You can use the material type you customize or create to make it faster and easier to set the appearance of materials in your project. When you add a property to a material type, Kanzi Studio adds the property to all materials using that material type.

To add a property to a material type:

  1. In the Library > Materials and Textures > Material Types select the material type to which you want to add a property.
  2. In the Properties in the Input section from the dropdown menu select the property you want to add.
  3. In the Library > Resource Files > Shaders double-click the shader where you want to use the property to open it in the Shader Source Editor.
  4. Add the property to the shader code and save the shader. You can use code snippets to declare a uniform by clicking the Uniforms button in the Shader Source Editor. See Editing shaders.

Reusing material types

When you create a material type in your Kanzi Studio project, you can reuse the material type in another Kanzi Studio project.

To reuse material types:

  1. Save the material type:
    1. In the Library > Materials and Textures > Material Types right-click the material type that you want to use in another project, and select Save Material Type to Disk.
    2. Select the name and location where you want to save the material type and click Save.
  2. Reuse the material type:
    1. In Kanzi Studio open the project to which you want to load the material type that you saved.
    2. In the Library right-click Materials and Textures, select Load Material Type From Disk, go to the directory that contains the material type that you saved, select the material type and click Open.
      Kanzi Studio adds the material type and creates a material using that material type. You can create additional materials from the same material type. See Using materials.

Material Type property types

For a list of the available property types for material types, see Material type.

See also

Using materials

Material types and materials

Editing shaders

Using Morph resources

Using skinned meshes

Setting the number of lights for a material type